package carmensd.vista.expedienteYvillanos

import applicationModel.EditarHobbiesVillanoAppModel
import applicationModel.EditarSeniasVillanoAppModel
import applicationModel.VillanoAppModel
import org.uqbar.arena.layout.VerticalLayout
import org.uqbar.arena.widgets.Button
import org.uqbar.arena.widgets.Label
import org.uqbar.arena.widgets.Panel
import org.uqbar.arena.widgets.Selector
import org.uqbar.arena.windows.Dialog
import org.uqbar.arena.windows.WindowOwner

abstract class VillanoMainWindow extends Dialog<VillanoAppModel> {

	
	new(WindowOwner owner, VillanoAppModel model) {
		super(owner, model)
	}
	
	override createContents(Panel nuevoVillanoPanel) {

		nuevoVillanoPanel.setLayout(new VerticalLayout)

		/* Nombre */
		new Label(nuevoVillanoPanel).setText("Nombre:" )
		AsistenteDeContenidos.colocarTextBoxConValueBindeado(nuevoVillanoPanel, "villanoEnEdicion.nombre")

		/* Sexo */
		new Label(nuevoVillanoPanel).setText("Sexo:")
		new Selector(nuevoVillanoPanel) => [
			allowNull(false)
			bindItemsToProperty("villanoEnEdicion.sexo")
		]

		/* Señas particulares */
		new Label(nuevoVillanoPanel).setText("Señas Particulares:")
		new Button(nuevoVillanoPanel) => [
			caption = "Editar Señas Particulares"
			onClick [|this.openDialog(new EditarSeniasWindow(this, new EditarSeniasVillanoAppModel(modelObject.villanoEnEdicion)))]
		]
		AsistenteDeContenidos.colocarListaConItemsBindeados(nuevoVillanoPanel, "villanoEnEdicion.seniasParticulares")

		/* Hobbies */
		new Label(nuevoVillanoPanel).setText("Hobbies:")
		new Button(nuevoVillanoPanel) => [
			caption = "Editar Hobbies"
			onClick [|this.openDialog(new EditarHobbiesWindow(this, new EditarHobbiesVillanoAppModel(modelObject.villanoEnEdicion)))]
		]
		AsistenteDeContenidos.colocarListaConItemsBindeados(nuevoVillanoPanel, "villanoEnEdicion.hobbies")
	}

	def openDialog(Dialog<?> dialog) {
		dialog.onAccept[|this.modelObject]
		dialog.open
	}

	override protected createFormPanel(Panel mainPanel) {
		throw new UnsupportedOperationException("TODO: auto-generated method stub")
	}

}
